package com.fauks.gmall.managerweb.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.fauks.gmall.bean.PmsBaseAttrInfo;
import com.fauks.gmall.bean.PmsBaseAttrValue;
import com.fauks.gmall.bean.PmsBaseSaleAttr;
import com.fauks.gmall.service.AttrService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@CrossOrigin
public class AttrController {

    @Reference
    private AttrService attrService;

    @GetMapping("attrInfoList")
    @ResponseBody
    public List<PmsBaseAttrInfo> attrInfoList(String catalog3Id) {
        return attrService.attrInfoList(catalog3Id);
    }

    /**
     * 保存更新通用接口
     *
     * @param pmsBaseAttrInfo
     * @return
     */
    @RequestMapping("saveAttrInfo")
    @ResponseBody
    public String saveAttrInfo(@RequestBody PmsBaseAttrInfo pmsBaseAttrInfo) {
        String result = attrService.saveAttrInfo(pmsBaseAttrInfo);
        return "success";
    }

    @RequestMapping("getAttrValueList")
    @ResponseBody
    public List<PmsBaseAttrValue> getAttrValueList(String attrId) {
        return attrService.getAttrValueList(attrId);
    }

    /**
     * 获取商品销售属性
     *
     * @return
     */
    @PostMapping("baseSaleAttrList")
    @ResponseBody
    public List<PmsBaseSaleAttr> baseSaleAttrList() {
        return attrService.getBaseSaleAttrList();
    }
}
